package com.ihighest.app.infox.activity;

import org.json.JSONException;

import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;

import com.ihighest.app.common.api.Api;
import com.ihighest.app.common.api.ApiCallback;
import com.ihighest.app.common.api.ApiParam;
import com.ihighest.app.common.api.ApiResult;
import com.ihighest.app.infox.R;
import com.ihighest.app.infox.myview.ActivityTitle;

/**
 * 消息详情界面
 * 
 * @author lkx Created at 2015-11-6 上午9:57:39
 * @version 1.0
 */
public class MassageDetailActivity extends BaseActivity {
	private ActivityTitle title;
	private String mId;// 消息ID
	private TextView massageContent;
	private WebView contentView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.infox_activity_massagedeatil);
		mId = getIntent().getStringExtra("massageId");
		initView();

		initData();
	}

	/**
	 * 获取数据
	 * 
	 * 
	 * @author lkx Created at 2015-11-6 上午10:07:50
	 */
	private void initData() {
		Api.get("me/messageDetail", ApiParam.create().addParam("id", mId), new ApiCallback(MassageDetailActivity.this) {

			@Override
			public void handleSuccess(ApiResult result) {
				try {
					// massageContent.setText(result.getData().getString("content"));
					contentView.loadDataWithBaseURL(null, result.getData().getString("content"), "text/html", "utf-8", null);
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}

			@Override
			public void handleFailure(Exception e, String msg) {
				// TODO Auto-generated method stub

			}
		}, MassageDetailActivity.this);

	}

	/**
	 * 绑定
	 * 
	 * 
	 * @author lkx Created at 2015-11-6 上午10:06:09
	 */
	private void initView() {
		title = (ActivityTitle) findViewById(R.id.massageDetailTitle);
		title.setTitle("消息详情");
		title.setViewVersible(title.titleBack);
		title.setViewGone(title.titleMsg, title.titleRefresh, title.rightLayout);
		massageContent = (TextView) findViewById(R.id.massageContent);
		contentView = (WebView) findViewById(R.id.contentWebView);
	}
}
